package com.wc.alorithm_luogu._动态规划._线性DP.P1002;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/7/19 13:28
 * 过河卒
 * @description https://www.luogu.com.cn/problem/P1002
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int bX = sc.nextInt();
        int bY = sc.nextInt();
        int m = sc.nextInt();
        int n = sc.nextInt();

        Main main = new Main();
        long[][] arr = new long[bX + 1][bY + 1];
        boolean[][] horses = new boolean[bX + 1][bY + 1];

        main.paintHorse(horses, m, n);
        System.out.println(main.getAns(arr, bX, bY, horses));
//        main.printArr(arr);
    }

    public long getAns(long[][] arr, int bX, int bY, boolean[][] horses) {
        if (horses[0][0] || horses[bX][bY]) {
            return 0;
        }
        arr[0][0] = 1;

        // 规划第一行
        for (int i = 1; i <= bY; i++) {
            if (!horses[0][i]) {
                arr[0][i] = arr[0][i - 1];
            }
        }
        // 规划第一列
        for (int i = 1; i <= bX; i++) {
            if (!horses[i][0]) {
                arr[i][0] = arr[i - 1][0];
            }
        }

        for (int i = 1; i <= bX; i++) {
            for (int j = 1; j <= bY; j++) {
                if (!horses[i][j]) {
                    arr[i][j] = arr[i - 1][j] + arr[i][j - 1];
                }
            }
        }

        return arr[bX][bY];
    }

    public void printArr(long[][] arr) {
        StringBuffer str = new StringBuffer();

        for (long[] row : arr) {
            for (long num : row) {
                str.append(num);
                str.append('\t');
            }
            str.append('\n');
        }
        System.out.println(str);
    }

    private final int[] x = {-1, 1, -2, -2, -1, 1, 2, 2};
    private final int[] y = {-2, 2, -1, 1, 2, -2, -1, 1};

    /**
     * 为马走的位置涂色
     *
     * @param horses 涂色盘
     * @param m      横坐标
     * @param n      纵坐标
     */
    public void paintHorse(boolean[][] horses, int m, int n) {
        horses[m][n] = true;
        int left = 0;
        int right = horses[0].length - 1;
        int up = 0;
        int down = horses.length - 1;
        for (int i = 0; i < x.length; i++) {
            int xx = m + x[i];
            int yy = n + y[i];
            if (xx >= left && xx <= right && yy >= up && yy <= down) {
                horses[xx][yy] = true;
            }
        }
    }
}
